? 20100430-repositoriesupdate-patch.patch
? config.php
? nbproject
Index: admin/repository.php
===================================================================
RCS file: /cvsroot/moodle/moodle/admin/repository.php,v
retrieving revision 1.37
diff -r1.37 repository.php
7,13c7,9
< $edit = optional_param('edit', 0, PARAM_FORMAT);
< $new = optional_param('new', '', PARAM_FORMAT);
< $hide = optional_param('hide', '', PARAM_FORMAT);
< $delete = optional_param('delete', 0, PARAM_FORMAT);
< $sure = optional_param('sure', '', PARAM_ALPHA);
< $move = optional_param('move', '', PARAM_ALPHANUM);
< $type = optional_param('type', '', PARAM_ALPHANUM);
---
> $repository = optional_param('repos', '', PARAM_FORMAT);
> $action = optional_param('action', '', PARAM_ALPHA);
> $sure = optional_param('sure', '', PARAM_ALPHA);
19,21c15,17
< if ($edit) {
< $pagename = 'repositorysettings' . $edit;
< } else if ($delete) {
---
> if ($action == 'edit') {
> $pagename = 'repositorysettings' . $repository;
> } else if ($action == 'delete') {
23c19
< } else if ($new) {
---
> } else if (($action == 'newon') || ($action == 'newoff')) {
26a23,34
> // Need to remember this for form
> $formaction = $action;
>
> // Check what visibility to show the new repository
> if ($action == 'newon') {
> $action = 'new';
> $visible = true;
> } else if ($action == 'newoff') {
> $action = 'new';
> $visible = false;
> }
>
37,39c45,47
< if (!empty($edit) || !empty($new)) {
< if (!empty($edit)) {
< $repositorytype = repository::get_type_by_typename($edit);
---
> if (($action == 'edit') || ($action == 'new')) {
> if ($action == 'edit') {
> $repositorytype = repository::get_type_by_typename($repository);
45,46c53,54
< $plugin = $new;
< $typeid = $new;
---
> $plugin = $repository;
> $typeid = $repository;
50c58
< $mform = new repository_type_form('', array('plugin' => $plugin, 'instance' => $repositorytype));
---
> $mform = new repository_type_form('', array('plugin' => $plugin, 'instance' => $repositorytype, 'action' => $formaction));
55,56c63,64
< if (!empty($new)) {
< $adminconfignames = repository::static_function($new, 'get_type_option_names');
---
> if ($action == 'new') {
> $adminconfignames = repository::static_function($repository, 'get_type_option_names');
64,67c72,73
< if (!confirm_sesskey()) {
< print_error('confirmsesskeybad', '', $baseurl);
< }
< if ($edit) {
---
> require_sesskey();
> if ($action == 'edit') {
78c84
< $instanceoptionnames = repository::static_function($edit, 'get_instance_option_names');
---
> $instanceoptionnames = repository::static_function($repository, 'get_instance_option_names');
95c101
< $type = new repository_type($plugin, (array)$fromform);
---
> $type = new repository_type($plugin, (array)$fromform, $visible);
101,109c107,108
< $has_instance = repository::static_function($plugin, 'get_instance_option_names');
<
< if (!empty($has_instance)) {
< // no common setting for this type, so go to setup instances
< redirect($sesskeyurl.'&edit='.$plugin);
< } else {
< // configs saved
< redirect($baseurl);
< }
---
> // configs saved
> redirect($baseurl);
118,120c117,119
< if ($edit) {
< $typeoptionnames = repository::static_function($edit, 'get_type_option_names');
< $instanceoptionnames = repository::static_function($edit, 'get_instance_option_names');
---
> if ($action == 'edit') {
> $typeoptionnames = repository::static_function($repository, 'get_type_option_names');
> $instanceoptionnames = repository::static_function($repository, 'get_instance_option_names');
132,134c131,133
< //display instances list and creation form
< if ($edit){
< $instanceoptionnames = repository::static_function($edit, 'get_instance_option_names');
---
> // Display instances list and creation form
> if ($action == 'edit'){
> $instanceoptionnames = repository::static_function($repository, 'get_instance_option_names');
136c135
< repository::display_instances_list(get_context_instance(CONTEXT_SYSTEM), $edit);
---
> repository::display_instances_list(get_context_instance(CONTEXT_SYSTEM), $repository);
141c140,150
< } else if (!empty($hide)) {
---
> } else if ($action == 'show') {
> if (!confirm_sesskey()) {
> print_error('confirmsesskeybad', '', $baseurl);
> }
> $repositorytype = repository::get_type_by_typename($repository);
> if (empty($repositorytype)) {
> print_error('invalidplugin', 'repository', '', $repository);
> }
> $repositorytype->update_visibility(true);
> $return = true;
> } else if ($action == 'hide') {
145c154
< $repositorytype = repository::get_type_by_typename($hide);
---
> $repositorytype = repository::get_type_by_typename($repository);
147c156
< print_error('invalidplugin', 'repository', '', $hide);
---
> print_error('invalidplugin', 'repository', '', $repository);
149c158
< $repositorytype->switch_and_update_visibility();
---
> $repositorytype->update_visibility(false);
151,152c160,161
< } else if (!empty($delete)) {
< $repositorytype = repository::get_type_by_typename($delete);
---
> } else if ($action == 'delete') {
> $repositorytype = repository::get_type_by_typename($repository);
154c163
< $PAGE->set_pagetype('admin-repository-' . $delete);
---
> $PAGE->set_pagetype('admin-repository-' . $repository);
166c175
< echo $OUTPUT->confirm(get_string('confirmremove', 'repository', $repositorytype->get_readablename()), $sesskeyurl . '&delete=' . $delete . '&sure=yes', $baseurl);
---
> echo $OUTPUT->confirm(get_string('confirmremove', 'repository', $repositorytype->get_readablename()), $sesskeyurl . '&action=delete&repos=' . $repository . '&sure=yes', $baseurl);
169,172c178,183
< }
< else if (!empty($move) && !empty($type)) {
< $repositorytype = repository::get_type_by_typename($type);
< $repositorytype->move_order($move);
---
> } else if ($action == 'moveup') {
> $repositorytype = repository::get_type_by_typename($repository);
> $repositorytype->move_order('up');
> } else if ($action == 'movedown') {
> $repositorytype = repository::get_type_by_typename($repository);
> $repositorytype->move_order('down');
Index: admin/repositoryinstance.php
===================================================================
RCS file: /cvsroot/moodle/moodle/admin/repositoryinstance.php,v
retrieving revision 1.18
diff -r1.18 repositoryinstance.php
31c31
< $baseurl = "$CFG->wwwroot/$CFG->admin/repository.php?session=". sesskey() .'&edit=';
---
> $baseurl = "$CFG->wwwroot/$CFG->admin/repository.php?session=". sesskey() .'&action=edit&repos=';
56c56
< $mform = new repository_instance_form('', array('plugin' => $plugin, 'typeid' => $typeid,'instance' => $instance, 'contextid' => $context->id));
---
> $mform = new repository_instance_form('', array('plugin' => $plugin, 'typeid' => $typeid, 'instance' => $instance, 'contextid' => $context->id));
101d100
< echo $OUTPUT->header();
113d111
< echo $OUTPUT->heading($deletedstr);
120a119
> echo $OUTPUT->header();
Index: admin/settings/plugins.php
===================================================================
RCS file: /cvsroot/moodle/moodle/admin/settings/plugins.php,v
retrieving revision 1.74
diff -r1.74 plugins.php
236c236
< $url . '?edit=' . $repositorytype->get_typename()),
---
> $url . '?action=edit&repos=' . $repositorytype->get_typename()),
Index: lang/en/repository.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lang/en/repository.php,v
retrieving revision 1.2
diff -r1.2 repository.php
52,53d51
< $string['clicktohide'] = 'Click here to hide';
< $string['clicktoshow'] = 'Click here to show';
89c87
< $string['hiddenshow'] = 'Hide/Show';
---
> $string['hidden'] = 'Hidden';
100a99
> $string['isactive'] = 'Active?';
116a116
> $string['off'] = 'Off';
118a119
> $string['on'] = 'On';
148d148
< $string['updown'] = 'Display order';
Index: lib/adminlib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/adminlib.php,v
retrieving revision 1.456
diff -r1.456 adminlib.php
1170c1170
< // do not use defaults if settings not available - upgrdesettings handles the defaults!
---
> // do not use defaults if settings not available - upgrade settings handles the defaults!
1481c1481
< $return .= $OUTPUT->heading(''.highlightfast($query, $this->visiblename).'', 3, 'main', true);
---
> $return .= $OUTPUT->heading($this->visiblename, 3, 'main', true);
6083a6084,6092
> * Helper function that generates a moodle_url object
> * relevant to the repository
> */
>
> function repository_action_url($repository) {
> return new moodle_url('/admin/repository.php', array('sesskey'=>sesskey(), 'repos'=>$repository));
> }
>
> /**
6092,6093c6101,6117
< $output = $OUTPUT->box_start('generalbox');
< $namestr = get_string('name');
---
>
> $actionchoicesforexisting = array(
> 'show' => get_string('on', 'repository'),
> 'hide' => get_string('off', 'repository'),
> 'delete' => get_string('disable')
> );
>
> $actionchoicesfornew = array(
> 'newon' => get_string('on', 'repository'),
> 'newoff' => get_string('off', 'repository'),
> 'delete' => get_string('disable')
> );
>
> $return = '';
> $return .= $OUTPUT->box_start('generalbox');
>
> // Set strings that are used multiple times
6095,6101c6119,6121
< $updownstr = get_string('updown', 'repository');
< $hiddenstr = get_string('hiddenshow', 'repository');
< $deletestr = get_string('delete');
< $plugins = get_plugin_list('repository');
< $instances = repository::get_types();
< $instancesnumber = count($instances);
< $alreadyplugins = array();
---
> $disablestr = get_string('disable');
>
> // Table to list plug-ins
6103,6104c6123,6124
< $table->head = array($namestr, $updownstr, $hiddenstr, $deletestr, $settingsstr);
< $table->align = array('left', 'center', 'center','center','center');
---
> $table->head = array(get_string('name'), get_string('isactive', 'repository'), get_string('order'), $settingsstr);
> $table->align = array('left', 'center', 'center', 'center', 'center');
6106,6132d6125
< $updowncount=1;
< foreach ($instances as $i) {
< $settings = '';
< //display edit link only if you can config the type or if it has multiple instances (e.g. has instance config)
< $typeoptionnames = repository::static_function($i->get_typename(), 'get_type_option_names');
< $instanceoptionnames = repository::static_function($i->get_typename(), 'get_instance_option_names');
<
< if ( !empty($typeoptionnames) || !empty($instanceoptionnames)) {
<
< //calculate number of instances in order to display them for the Moodle administrator
< if (!empty($instanceoptionnames)) {
< $params = array();
< $params['context'] = array(get_system_context());
< $params['onlyvisible'] = false;
< $params['type'] = $i->get_typename();
< $admininstancenumber = count(repository::static_function($i->get_typename(),
< 'get_instances', $params));
< $admininstancenumbertext = "
". $admininstancenumber .
< " " . get_string('instancesforadmin', 'repository');
< $params['context'] = array();
< $instancenumber = count(repository::static_function($i->get_typename(), 'get_instances', $params)) - $admininstancenumber;
< $instancenumbertext = "
" . $instancenumber .
< " " . get_string('instancesforothers', 'repository');
< } else {
< $admininstancenumbertext = "";
< $instancenumbertext = "";
< }
6134,6138c6127,6156
< $settings .= ''
< . $settingsstr .'' . $admininstancenumbertext . $instancenumbertext . "\n";
< }
< $delete = ''
< . $deletestr . '' . "\n";
---
> // Get list of used plug-ins
> $instances = repository::get_types();
> if (!empty($instances)) {
> // Array to store plugins being used
> $alreadyplugins = array();
> $totalinstances = count($instances);
> $updowncount = 1;
> foreach ($instances as $i) {
> $settings = '';
> $typename = $i->get_typename();
> // Display edit link only if you can config the type or if it has multiple instances (e.g. has instance config)
> $typeoptionnames = repository::static_function($typename, 'get_type_option_names');
> $instanceoptionnames = repository::static_function($typename, 'get_instance_option_names');
>
> if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
> // Calculate number of instances in order to display them for the Moodle administrator
> if (!empty($instanceoptionnames)) {
> $params = array();
> $params['context'] = array(get_system_context());
> $params['onlyvisible'] = false;
> $params['type'] = $typename;
> $admininstancenumber = count(repository::static_function($typename, 'get_instances', $params));
> $admininstancenumbertext = "
". $admininstancenumber . " " . get_string('instancesforadmin', 'repository');
> $params['context'] = array();
> $instancenumber = count(repository::static_function($typename, 'get_instances', $params)) - $admininstancenumber;
> $instancenumbertext = "
" . $instancenumber . " " . get_string('instancesforothers', 'repository');
> } else {
> $admininstancenumbertext = "";
> $instancenumbertext = "";
> }
6140,6145c6158,6167
< $hidetitle = $i->get_visible() ? get_string('clicktohide', 'repository') : get_string('clicktoshow', 'repository');
< $hiddenshow = ' '
< .''
< .'' . "\n";
---
> $settings .= '' . $settingsstr .'' . $admininstancenumbertext . $instancenumbertext . "\n";
> }
> // Get the current visibility
> if ($i->get_visible()) {
> $currentaction = 'show';
> } else {
> $currentaction = 'hide';
> }
>
> $select = new single_select($this->repository_action_url($typename, 'repos'), 'action', $actionchoicesforexisting, $currentaction, null, 'applyto' . basename($typename));
6147,6149c6169,6171
< // display up/down link
< $updown = '';
< $spacer = $OUTPUT->spacer(array('height'=>15, 'width'=>15)); // should be done with CSS instead
---
> // Display up/down link
> $updown = '';
> $spacer = $OUTPUT->spacer(array('height'=>15, 'width'=>15)); // should be done with CSS instead
6151,6166c6173,6186
< if ($updowncount > 1) {
< $updown .= "baseurl&move=up&type=".$i->get_typename()."\">";
< $updown .= "
pix_url('t/up') . "\" alt=\"up\" /> ";
< }
< else {
< $updown .= $spacer;
< }
< if ($updowncount < count($instances)) {
< $updown .= "baseurl&move=down&type=".$i->get_typename()."\">";
< $updown .= "
pix_url('t/down') . "\" alt=\"down\" />";
< }
< else {
< $updown .= $spacer;
< }
<
< $updowncount++;
---
> if ($updowncount > 1) {
> $updown .= "baseurl&action=moveup&repos=".$typename."\">";
> $updown .= "
pix_url('t/up') . "\" alt=\"up\" /> ";
> }
> else {
> $updown .= $spacer;
> }
> if ($updowncount < $totalinstances) {
> $updown .= "baseurl&action=movedown&repos=".$typename."\">";
> $updown .= "
pix_url('t/down') . "\" alt=\"down\" />";
> }
> else {
> $updown .= $spacer;
> }
6168c6188
< $table->data[] = array($i->get_readablename(), $updown, $hiddenshow, $delete, $settings);
---
> $updowncount++;
6170,6175c6190
< //display a grey row if the type is defined as not visible
< if (!$i->get_visible()) {
< $table->rowclasses[] = 'dimmed_text';
< } else {
< $table->rowclasses[] = '';
< }
---
> $table->data[] = array($i->get_readablename(), $OUTPUT->render($select), $updown, $settings);
6177,6178c6192,6194
< if (!in_array($i->get_typename(), $alreadyplugins)) {
< $alreadyplugins[] = $i->get_typename();
---
> if (!in_array($typename, $alreadyplugins)) {
> $alreadyplugins[] = $typename;
> }
6181,6192c6197,6206
< $output .= html_writer::table($table);
< $instancehtml = '